package prv.pursuivant.core.impl;

import java.util.Iterator;
import java.util.Map;

import prv.pursuivant.core.AchievType;
import prv.pursuivant.core.Achievement;
import prv.pursuivant.core.ToonAchievements;

import com.google.inject.Inject;

public class ToonAchievementsImpl implements ToonAchievements {

	private final Map<String, Achievement> achievements;

	@Inject
	public ToonAchievementsImpl(Map<String, Achievement> achievments) {
		this.achievements = achievments;
	}

	@Override
	public Achievement get(AchievType achievType) {
		return achievements.get(achievType.getId());
	}

	@Override
	public Achievement get(String achievTypeId) {
		return achievements.get(achievTypeId);
	}

	@Override
	public boolean contains(AchievType achievType) {
		return achievements.containsKey(achievType.getId());
	}

	@Override
	public boolean contains(String achievTypeId) {
		return achievements.containsKey(achievTypeId);
	}

	@Override
	public boolean equals(Object obj) {
		return obj instanceof ToonAchievementsImpl
				&& this.achievements
						.equals(((ToonAchievementsImpl) obj).achievements);
	}

	@Override
	public int hashCode() {
		return achievements.hashCode();
	}

	@Override
	public Iterator<Achievement> iterator() {
		return achievements.values().iterator();
	}

}
